
#include <BReadWrite>
#include "member_BStyle.h"
#include "member_BObject.h"
#include "member_BWidget.h"
#include "member_BLayout.h"
#include "member_BGraphicItem.h"
#include "IAlignItem.h"
#include "IGlobal.h"

using namespace BWE;

member_BStyle::member_BStyle(BStyle* style)
{
	boss = style;
	parent = 0;
	heritable = true;
	descendant = true;
}
member_BStyle::~member_BStyle()
{

}

void member_BStyle::init(const BColor& color)
{
	valueMap.clear();
	colorMap.clear();
	imageMap.clear();
	iconMap.clear();
	namedValueMap.clear();
	namedColorMap.clear();
	namedImageMap.clear();
	namedIconMap.clear();
	transMap.clear();
	wordMap.clear();
	textMap.clear();
	annexes.clear();
	children.clear();

	if (color.gray() > 127)
	{
		BColor background(color.gray() + (255 - color.gray()) / 2);
		colorMap[Color_Background] = background % 96;
		colorMap[Color_Background + State_Normal] = background % 96;
		colorMap[Color_Background + State_Normal_Hovered] = background % 86;
		colorMap[Color_Background + State_Normal_Pressed] = background % 72;
		colorMap[Color_Background + State_Normal_Selected] = background % 72;

		colorMap[Color_Background + State_Actived] = background % 96;
		colorMap[Color_Background + State_Actived_Hovered] = background % 86;
		colorMap[Color_Background + State_Actived_Pressed] = background % 72;
		colorMap[Color_Background + State_Actived_Selected] = background % 72;

		colorMap[Color_Background + State_Checked] = color % 76;
		colorMap[Color_Background + State_Checked_Hovered] = color % 86;
		colorMap[Color_Background + State_Checked_Pressed] = color % 72;
		colorMap[Color_Background + State_Checked_Selected] = color % 72;

		colorMap[Color_Background + State_Disable] = background % 66;
		colorMap[Color_Background + State_Disable_Hovered] = background % 86;
		colorMap[Color_Background + State_Disable_Pressed] = background % 72;
		colorMap[Color_Background + State_Disable_Selected] = background % 72;
	}
	else
	{
		BColor background(color.gray() / 2);
		colorMap[Color_Background] = background % 56;

		colorMap[Color_Background + State_Normal] = background % 56;
		colorMap[Color_Background + State_Normal_Hovered] = background % 86;
		colorMap[Color_Background + State_Normal_Pressed] = background % 66;
		colorMap[Color_Background + State_Normal_Selected] = background % 66;

		colorMap[Color_Background + State_Actived] = background % 66;
		colorMap[Color_Background + State_Actived_Hovered] = background % 86;
		colorMap[Color_Background + State_Actived_Pressed] = background % 66;
		colorMap[Color_Background + State_Actived_Selected] = background % 66;

		colorMap[Color_Background + State_Checked] = color % 76;
		colorMap[Color_Background + State_Checked_Hovered] = color % 86;
		colorMap[Color_Background + State_Checked_Pressed] = color % 66;
		colorMap[Color_Background + State_Checked_Selected] = color % 66;

		colorMap[Color_Background + State_Disable] = background % 46;
		colorMap[Color_Background + State_Disable_Hovered] = background % 86;
		colorMap[Color_Background + State_Disable_Pressed] = background % 66;
		colorMap[Color_Background + State_Disable_Selected] = background % 66;
	}

	if (color.gray() > 127)
	{
		colorMap[Color_Text] = BColor(0);
		colorMap[Color_Text + State_Normal] = BColor(0);
		colorMap[Color_Text + State_Normal_Hovered] = BColor(55);
		colorMap[Color_Text + State_Normal_Pressed] = BColor(44);
		colorMap[Color_Text + State_Normal_Selected] = BColor(50);

		colorMap[Color_Text + State_Actived] = BColor(0);
		colorMap[Color_Text + State_Actived_Hovered] = BColor(55);
		colorMap[Color_Text + State_Actived_Pressed] = BColor(44);
		colorMap[Color_Text + State_Actived_Selected] = BColor(50);

		colorMap[Color_Text + State_Disable] = BColor(33);
		colorMap[Color_Text + State_Disable_Hovered] = BColor(55);
		colorMap[Color_Text + State_Disable_Pressed] = BColor(44);
		colorMap[Color_Text + State_Disable_Selected] = BColor(44);

		colorMap[Color_Text + State_Checked] = BColor(66);
		colorMap[Color_Text + State_Checked_Hovered] = BColor(55);
		colorMap[Color_Text + State_Checked_Pressed] = BColor(44);
		colorMap[Color_Text + State_Checked_Selected] = BColor(44);

		colorMap[Color_Border] = color % 80;
		colorMap[Color_Border + State_Normal] = color % 80;
		colorMap[Color_Border + State_Normal_Hovered] = color % 70;
		colorMap[Color_Border + State_Normal_Pressed] = color % 80;
		colorMap[Color_Border + State_Normal_Selected] = color % 80;

		colorMap[Color_Border + State_Actived] = color % 80;
		colorMap[Color_Border + State_Actived_Hovered] = color % 70;
		colorMap[Color_Border + State_Actived_Pressed] = color % 80;
		colorMap[Color_Border + State_Actived_Selected] = color % 80;

		colorMap[Color_Border + State_Checked] = color % 76;
		colorMap[Color_Border + State_Checked_Hovered] = color % 70;
		colorMap[Color_Border + State_Checked_Pressed] = color % 80;
		colorMap[Color_Border + State_Checked_Selected] = color % 80;

		colorMap[Color_Border + State_Disable] = color % 76;
		colorMap[Color_Border + State_Disable_Hovered] = color % 70;
		colorMap[Color_Border + State_Disable_Pressed] = color % 80;
		colorMap[Color_Border + State_Disable_Selected] = color % 80;

		colorMap[Color_Perch] = color % 86;
		colorMap[Color_Perch + State_Normal] = color % 86;
		colorMap[Color_Perch + State_Normal_Hovered] = color % 90;
		colorMap[Color_Perch + State_Normal_Pressed] = color % 70;
		colorMap[Color_Perch + State_Normal_Selected] = color % 70;

		colorMap[Color_Perch + State_Actived] = color % 86;
		colorMap[Color_Perch + State_Actived_Hovered] = color % 90;
		colorMap[Color_Perch + State_Actived_Pressed] = color % 70;
		colorMap[Color_Perch + State_Actived_Selected] = color % 70;

		colorMap[Color_Perch + State_Checked] = color % 80;
		colorMap[Color_Perch + State_Checked_Hovered] = color % 84;
		colorMap[Color_Perch + State_Checked_Pressed] = color % 70;
		colorMap[Color_Perch + State_Checked_Selected] = color % 70;

		colorMap[Color_Perch + State_Disable] = color % 60;
		colorMap[Color_Perch + State_Disable_Hovered] = color % 64;
		colorMap[Color_Perch + State_Disable_Pressed] = color % 70;
		colorMap[Color_Perch + State_Disable_Selected] = color % 70;

		colorMap[Color_Handle] = color % 80;
		colorMap[Color_Handle + State_Normal] = color % 80;
		colorMap[Color_Handle + State_Normal_Hovered] = color % 70;
		colorMap[Color_Handle + State_Normal_Pressed] = color % 60;
		colorMap[Color_Handle + State_Normal_Selected] = color % 60;

		colorMap[Color_Handle + State_Actived] = color % 80;
		colorMap[Color_Handle + State_Actived_Hovered] = color % 70;
		colorMap[Color_Handle + State_Actived_Pressed] = color % 60;
		colorMap[Color_Handle + State_Actived_Selected] = color % 60;

		colorMap[Color_Handle + State_Checked] = color % 66;
		colorMap[Color_Handle + State_Checked_Hovered] = color % 70;
		colorMap[Color_Handle + State_Checked_Pressed] = color % 60;
		colorMap[Color_Handle + State_Checked_Selected] = color % 60;

		colorMap[Color_Handle + State_Disable] = color % 56;
		colorMap[Color_Handle + State_Disable_Hovered] = color % 70;
		colorMap[Color_Handle + State_Disable_Pressed] = color % 60;
		colorMap[Color_Handle + State_Disable_Selected] = color % 60;

		colorMap[Color_Chunk] = color % 80;
		colorMap[Color_Chunk + State_Normal] = color % 80;
		colorMap[Color_Chunk + State_Normal_Hovered] = color % 70;
		colorMap[Color_Chunk + State_Normal_Pressed] = color % 60;
		colorMap[Color_Chunk + State_Normal_Selected] = color % 60;

		colorMap[Color_Chunk + State_Actived] = color % 80;
		colorMap[Color_Chunk + State_Actived_Hovered] = color % 70;
		colorMap[Color_Chunk + State_Actived_Pressed] = color % 60;
		colorMap[Color_Chunk + State_Actived_Selected] = color % 60;

		colorMap[Color_Chunk + State_Checked] = color % 66;
		colorMap[Color_Chunk + State_Checked_Hovered] = color % 70;
		colorMap[Color_Chunk + State_Checked_Pressed] = color % 60;
		colorMap[Color_Chunk + State_Checked_Selected] = color % 60;

		colorMap[Color_Chunk + State_Disable] = color % 56;
		colorMap[Color_Chunk + State_Disable_Hovered] = color % 70;
		colorMap[Color_Chunk + State_Disable_Pressed] = color % 60;
		colorMap[Color_Chunk + State_Disable_Selected] = color % 60;

		colorMap[Color_Arrow] = color % 10;
		colorMap[Color_Arrow + State_Normal] = color % 10;
		colorMap[Color_Arrow + State_Normal_Hovered] = color % 28;
		colorMap[Color_Arrow + State_Normal_Pressed] = color % 15;
		colorMap[Color_Arrow + State_Normal_Selected] = color % 15;

		colorMap[Color_Arrow + State_Actived] = color % 10;
		colorMap[Color_Arrow + State_Actived_Hovered] = color % 28;
		colorMap[Color_Arrow + State_Actived_Pressed] = color % 15;
		colorMap[Color_Arrow + State_Actived_Selected] = color % 15;

		colorMap[Color_Arrow + State_Checked] = color % 36;
		colorMap[Color_Arrow + State_Checked_Hovered] = color % 28;
		colorMap[Color_Arrow + State_Checked_Pressed] = color % 15;
		colorMap[Color_Arrow + State_Checked_Selected] = color % 15;

		colorMap[Color_Arrow + State_Disable] = color % 56;
		colorMap[Color_Arrow + State_Disable_Hovered] = color % 28;
		colorMap[Color_Arrow + State_Disable_Pressed] = color % 15;
		colorMap[Color_Arrow + State_Disable_Selected] = color % 15;

		colorMap[Color_Wire] = color % 62;
		colorMap[Color_Wire + State_Normal] = color % 62;
		colorMap[Color_Wire + State_Normal_Hovered] = color % 66;
		colorMap[Color_Wire + State_Normal_Pressed] = color % 56;
		colorMap[Color_Wire + State_Normal_Selected] = color % 56;

		colorMap[Color_Wire + State_Actived] = color % 62;
		colorMap[Color_Wire + State_Actived_Hovered] = color % 66;
		colorMap[Color_Wire + State_Actived_Pressed] = color % 56;
		colorMap[Color_Wire + State_Actived_Selected] = color % 56;

		colorMap[Color_Wire + State_Checked] = color % 60;
		colorMap[Color_Wire + State_Checked_Hovered] = color % 66;
		colorMap[Color_Wire + State_Checked_Pressed] = color % 56;
		colorMap[Color_Wire + State_Checked_Selected] = color % 56;

		colorMap[Color_Wire + State_Disable] = color % 86;
		colorMap[Color_Wire + State_Disable_Hovered] = color % 66;
		colorMap[Color_Wire + State_Disable_Pressed] = color % 56;
		colorMap[Color_Wire + State_Disable_Selected] = color % 56;

		colorMap[Color_Selection] = color % 80;
		colorMap[Color_Selection + State_Normal] = color % 80;
		colorMap[Color_Selection + State_Normal_Hovered] = color % 70;
		colorMap[Color_Selection + State_Normal_Pressed] = color % 80;
		colorMap[Color_Selection + State_Normal_Selected] = color % 80;

		colorMap[Color_Selection + State_Actived] = color % 80;
		colorMap[Color_Selection + State_Actived_Hovered] = color % 70;
		colorMap[Color_Selection + State_Actived_Pressed] = color % 80;
		colorMap[Color_Selection + State_Actived_Selected] = color % 80;

		colorMap[Color_Selection + State_Checked] = color % 76;
		colorMap[Color_Selection + State_Checked_Hovered] = color % 70;
		colorMap[Color_Selection + State_Checked_Pressed] = color % 80;
		colorMap[Color_Selection + State_Checked_Selected] = color % 80;

		colorMap[Color_Selection + State_Disable] = color % 76;
		colorMap[Color_Selection + State_Disable_Hovered] = color % 70;
		colorMap[Color_Selection + State_Disable_Pressed] = color % 80;
		colorMap[Color_Selection + State_Disable_Selected] = color % 80;

		colorMap[Color_Indicator] = color % 10;
		colorMap[Color_Indicator + State_Normal] = color % 10;
		colorMap[Color_Indicator + State_Normal_Hovered] = color % 65;
		colorMap[Color_Indicator + State_Normal_Pressed] = color % 54;
		colorMap[Color_Indicator + State_Normal_Selected] = color % 60;

		colorMap[Color_Indicator + State_Actived] = color % 10;
		colorMap[Color_Indicator + State_Actived_Hovered] = color % 65;
		colorMap[Color_Indicator + State_Actived_Pressed] = color % 54;
		colorMap[Color_Indicator + State_Actived_Selected] = color % 60;

		colorMap[Color_Indicator + State_Disable] = color % 43;
		colorMap[Color_Indicator + State_Disable_Hovered] = color % 65;
		colorMap[Color_Indicator + State_Disable_Pressed] = color % 54;
		colorMap[Color_Indicator + State_Disable_Selected] = color % 54;

		colorMap[Color_Indicator + State_Checked] = color % 76;
		colorMap[Color_Indicator + State_Checked_Hovered] = color % 65;
		colorMap[Color_Indicator + State_Checked_Pressed] = color % 54;
		colorMap[Color_Indicator + State_Checked_Selected] = color % 54;

		colorMap[Color_Groove] = color % 66;
		colorMap[Color_Groove + State_Normal] = color % 66;
		colorMap[Color_Groove + State_Normal_Hovered] = color % 76;
		colorMap[Color_Groove + State_Normal_Pressed] = color % 50;
		colorMap[Color_Groove + State_Normal_Selected] = color % 50;

		colorMap[Color_Groove + State_Actived] = color % 66;
		colorMap[Color_Groove + State_Actived_Hovered] = color % 76;
		colorMap[Color_Groove + State_Actived_Pressed] = color % 50;
		colorMap[Color_Groove + State_Actived_Selected] = color % 50;

		colorMap[Color_Groove + State_Checked] = color % 60;
		colorMap[Color_Groove + State_Checked_Hovered] = color % 76;
		colorMap[Color_Groove + State_Checked_Pressed] = color % 50;
		colorMap[Color_Groove + State_Checked_Selected] = color % 50;

		colorMap[Color_Groove + State_Disable] = color % 40;
		colorMap[Color_Groove + State_Disable_Hovered] = color % 76;
		colorMap[Color_Groove + State_Disable_Pressed] = color % 50;
		colorMap[Color_Groove + State_Disable_Selected] = color % 50;

		colorMap[Color_Separator] = color % 76;
		colorMap[Color_Separator + State_Normal] = color % 76;
		colorMap[Color_Separator + State_Normal_Hovered] = color % 55;
		colorMap[Color_Separator + State_Normal_Pressed] = color % 44;
		colorMap[Color_Separator + State_Normal_Selected] = color % 50;

		colorMap[Color_Separator + State_Actived] = color % 76;
		colorMap[Color_Separator + State_Actived_Hovered] = color % 55;
		colorMap[Color_Separator + State_Actived_Pressed] = color % 44;
		colorMap[Color_Separator + State_Actived_Selected] = color % 50;

		colorMap[Color_Separator + State_Disable] = color % 33;
		colorMap[Color_Separator + State_Disable_Hovered] = color % 55;
		colorMap[Color_Separator + State_Disable_Pressed] = color % 44;
		colorMap[Color_Separator + State_Disable_Selected] = color % 44;

		colorMap[Color_Separator + State_Checked] = color % 66;
		colorMap[Color_Separator + State_Checked_Hovered] = color % 55;
		colorMap[Color_Separator + State_Checked_Pressed] = color % 44;
		colorMap[Color_Separator + State_Checked_Selected] = color % 44;

		colorMap[Color_Grid_Ver] = color % 80;
		colorMap[Color_Grid_Ver + State_Normal] = color % 80;
		colorMap[Color_Grid_Ver + State_Normal_Hovered] = color % 70;
		colorMap[Color_Grid_Ver + State_Normal_Pressed] = color % 80;
		colorMap[Color_Grid_Ver + State_Normal_Selected] = color % 80;

		colorMap[Color_Grid_Ver + State_Actived] = color % 80;
		colorMap[Color_Grid_Ver + State_Actived_Hovered] = color % 70;
		colorMap[Color_Grid_Ver + State_Actived_Pressed] = color % 80;
		colorMap[Color_Grid_Ver + State_Actived_Selected] = color % 80;

		colorMap[Color_Grid_Ver + State_Checked] = color % 76;
		colorMap[Color_Grid_Ver + State_Checked_Hovered] = color % 70;
		colorMap[Color_Grid_Ver + State_Checked_Pressed] = color % 80;
		colorMap[Color_Grid_Ver + State_Checked_Selected] = color % 80;

		colorMap[Color_Grid_Ver + State_Disable] = color % 76;
		colorMap[Color_Grid_Ver + State_Disable_Hovered] = color % 70;
		colorMap[Color_Grid_Ver + State_Disable_Pressed] = color % 80;
		colorMap[Color_Grid_Ver + State_Disable_Selected] = color % 80;

		colorMap[Color_Grid_Hor] = color % 66;
		colorMap[Color_Grid_Hor + State_Normal] = color % 80;
		colorMap[Color_Grid_Hor + State_Normal_Hovered] = color % 70;
		colorMap[Color_Grid_Hor + State_Normal_Pressed] = color % 80;
		colorMap[Color_Grid_Hor + State_Normal_Selected] = color % 80;

		colorMap[Color_Grid_Hor + State_Actived] = color % 80;
		colorMap[Color_Grid_Hor + State_Actived_Hovered] = color % 70;
		colorMap[Color_Grid_Hor + State_Actived_Pressed] = color % 80;
		colorMap[Color_Grid_Hor + State_Actived_Selected] = color % 80;

		colorMap[Color_Grid_Hor + State_Checked] = color % 76;
		colorMap[Color_Grid_Hor + State_Checked_Hovered] = color % 70;
		colorMap[Color_Grid_Hor + State_Checked_Pressed] = color % 80;
		colorMap[Color_Grid_Hor + State_Checked_Selected] = color % 80;

		colorMap[Color_Grid_Hor + State_Disable] = color % 76;
		colorMap[Color_Grid_Hor + State_Disable_Hovered] = color % 70;
		colorMap[Color_Grid_Hor + State_Disable_Pressed] = color % 80;
		colorMap[Color_Grid_Hor + State_Disable_Selected] = color % 80;

	}
	else
	{
		BColor textColor(255, 255, 255);
		colorMap[Color_Text] = textColor;
		colorMap[Color_Text + State_Normal] = textColor;
		colorMap[Color_Text + State_Normal_Hovered] = textColor % 120;
		colorMap[Color_Text + State_Normal_Pressed] = textColor;
		colorMap[Color_Text + State_Normal_Selected] = textColor;

		colorMap[Color_Text + State_Actived] = textColor;
		colorMap[Color_Text + State_Actived_Hovered] = textColor % 120;
		colorMap[Color_Text + State_Actived_Pressed] = textColor;
		colorMap[Color_Text + State_Actived_Selected] = textColor;

		colorMap[Color_Text + State_Checked] = textColor;
		colorMap[Color_Text + State_Checked_Hovered] = textColor % 120;
		colorMap[Color_Text + State_Checked_Pressed] = textColor;
		colorMap[Color_Text + State_Checked_Selected] = textColor;

		colorMap[Color_Text + State_Disable] = textColor % 70;
		colorMap[Color_Text + State_Disable_Hovered] = textColor % 120;
		colorMap[Color_Text + State_Disable_Pressed] = textColor;
		colorMap[Color_Text + State_Disable_Selected] = textColor;

		colorMap[Color_Border] = color % 120;
		colorMap[Color_Border + State_Normal] = color % 120;
		colorMap[Color_Border + State_Normal_Hovered] = color % 166;
		colorMap[Color_Border + State_Normal_Pressed] = color % 130;
		colorMap[Color_Border + State_Normal_Selected] = color % 130;

		colorMap[Color_Border + State_Actived] = color % 120;
		colorMap[Color_Border + State_Actived_Hovered] = color % 166;
		colorMap[Color_Border + State_Actived_Pressed] = color % 130;
		colorMap[Color_Border + State_Actived_Selected] = color % 130;

		colorMap[Color_Border + State_Checked] = color % 156;
		colorMap[Color_Border + State_Checked_Hovered] = color % 166;
		colorMap[Color_Border + State_Checked_Pressed] = color % 130;
		colorMap[Color_Border + State_Checked_Selected] = color % 130;

		colorMap[Color_Border + State_Disable] = color % 50;
		colorMap[Color_Border + State_Disable_Hovered] = color % 166;
		colorMap[Color_Border + State_Disable_Pressed] = color % 130;
		colorMap[Color_Border + State_Disable_Selected] = color % 130;

		colorMap[Color_Perch] = color;
		colorMap[Color_Perch + State_Normal] = color;
		colorMap[Color_Perch + State_Normal_Hovered] = color % 130;
		colorMap[Color_Perch + State_Normal_Pressed] = color % 110;
		colorMap[Color_Perch + State_Normal_Selected] = color % 110;

		colorMap[Color_Perch + State_Actived] = color;
		colorMap[Color_Perch + State_Actived_Hovered] = color % 130;
		colorMap[Color_Perch + State_Actived_Pressed] = color % 110;
		colorMap[Color_Perch + State_Actived_Selected] = color % 110;

		colorMap[Color_Perch + State_Checked] = color % 120;
		colorMap[Color_Perch + State_Checked_Hovered] = color % 130;
		colorMap[Color_Perch + State_Checked_Pressed] = color % 110;
		colorMap[Color_Perch + State_Checked_Selected] = color % 110;

		colorMap[Color_Perch + State_Disable] = color % 150;
		colorMap[Color_Perch + State_Disable_Hovered] = color % 130;
		colorMap[Color_Perch + State_Disable_Pressed] = color % 110;
		colorMap[Color_Perch + State_Disable_Selected] = color % 110;

		colorMap[Color_Handle] = color % 150;
		colorMap[Color_Handle + State_Normal] = color % 150;
		colorMap[Color_Handle + State_Normal_Hovered] = color % 166;
		colorMap[Color_Handle + State_Normal_Pressed] = color % 130;
		colorMap[Color_Handle + State_Normal_Selected] = color % 130;

		colorMap[Color_Handle + State_Actived] = color % 150;
		colorMap[Color_Handle + State_Actived_Hovered] = color % 166;
		colorMap[Color_Handle + State_Actived_Pressed] = color % 130;
		colorMap[Color_Handle + State_Actived_Selected] = color % 130;

		colorMap[Color_Handle + State_Checked] = color % 140;
		colorMap[Color_Handle + State_Checked_Hovered] = color % 166;
		colorMap[Color_Handle + State_Checked_Pressed] = color % 130;
		colorMap[Color_Handle + State_Checked_Selected] = color % 130;

		colorMap[Color_Handle + State_Disable] = color % 50;
		colorMap[Color_Handle + State_Disable_Hovered] = color % 166;
		colorMap[Color_Handle + State_Disable_Pressed] = color % 130;
		colorMap[Color_Handle + State_Disable_Selected] = color % 130;

		colorMap[Color_Chunk] = color % 150;
		colorMap[Color_Chunk + State_Normal] = color % 150;
		colorMap[Color_Chunk + State_Normal_Hovered] = color % 166;
		colorMap[Color_Chunk + State_Normal_Pressed] = color % 130;
		colorMap[Color_Chunk + State_Normal_Selected] = color % 130;

		colorMap[Color_Chunk + State_Actived] = color % 150;
		colorMap[Color_Chunk + State_Actived_Hovered] = color % 166;
		colorMap[Color_Chunk + State_Actived_Pressed] = color % 130;
		colorMap[Color_Chunk + State_Actived_Selected] = color % 130;

		colorMap[Color_Chunk + State_Checked] = color % 140;
		colorMap[Color_Chunk + State_Checked_Hovered] = color % 166;
		colorMap[Color_Chunk + State_Checked_Pressed] = color % 130;
		colorMap[Color_Chunk + State_Checked_Selected] = color % 130;

		colorMap[Color_Chunk + State_Disable] = color % 50;
		colorMap[Color_Chunk + State_Disable_Hovered] = color % 166;
		colorMap[Color_Chunk + State_Disable_Pressed] = color % 130;
		colorMap[Color_Chunk + State_Disable_Selected] = color % 130;

		colorMap[Color_Arrow] = textColor % 60;
		colorMap[Color_Arrow + State_Normal] = textColor % 60;
		colorMap[Color_Arrow + State_Normal_Hovered] = textColor % 80;
		colorMap[Color_Arrow + State_Normal_Pressed] = textColor % 66;
		colorMap[Color_Arrow + State_Normal_Selected] = textColor % 66;

		colorMap[Color_Arrow + State_Actived] = textColor % 60;
		colorMap[Color_Arrow + State_Actived_Hovered] = textColor % 80;
		colorMap[Color_Arrow + State_Actived_Pressed] = textColor % 66;
		colorMap[Color_Arrow + State_Actived_Selected] = textColor % 66;

		colorMap[Color_Arrow + State_Checked] = textColor % 66;
		colorMap[Color_Arrow + State_Checked_Hovered] = textColor % 80;
		colorMap[Color_Arrow + State_Checked_Pressed] = textColor % 66;
		colorMap[Color_Arrow + State_Checked_Selected] = textColor % 66;

		colorMap[Color_Arrow + State_Disable] = textColor % 36;
		colorMap[Color_Arrow + State_Disable_Hovered] = textColor % 80;
		colorMap[Color_Arrow + State_Disable_Pressed] = textColor % 66;
		colorMap[Color_Arrow + State_Disable_Selected] = textColor % 66;

		colorMap[Color_Wire] = color % 186;
		colorMap[Color_Wire + State_Normal] = color % 186;
		colorMap[Color_Wire + State_Normal_Hovered] = color % 136;
		colorMap[Color_Wire + State_Normal_Pressed] = color % 116;
		colorMap[Color_Wire + State_Normal_Selected] = color % 116;

		colorMap[Color_Wire + State_Actived] = color % 186;
		colorMap[Color_Wire + State_Actived_Hovered] = color % 136;
		colorMap[Color_Wire + State_Actived_Pressed] = color % 116;
		colorMap[Color_Wire + State_Actived_Selected] = color % 116;

		colorMap[Color_Wire + State_Checked] = color % 126;
		colorMap[Color_Wire + State_Checked_Hovered] = color % 136;
		colorMap[Color_Wire + State_Checked_Pressed] = color % 116;
		colorMap[Color_Wire + State_Checked_Selected] = color % 116;

		colorMap[Color_Wire + State_Disable] = color % 96;
		colorMap[Color_Wire + State_Disable_Hovered] = color % 136;
		colorMap[Color_Wire + State_Disable_Pressed] = color % 116;
		colorMap[Color_Wire + State_Disable_Selected] = color % 116;

		colorMap[Color_Indicator] = textColor;
		colorMap[Color_Indicator + State_Normal] = textColor;
		colorMap[Color_Indicator + State_Normal_Hovered] = textColor % 120;
		colorMap[Color_Indicator + State_Normal_Pressed] = textColor;
		colorMap[Color_Indicator + State_Normal_Selected] = textColor;

		colorMap[Color_Indicator + State_Actived] = textColor;
		colorMap[Color_Indicator + State_Actived_Hovered] = textColor % 120;
		colorMap[Color_Indicator + State_Actived_Pressed] = textColor;
		colorMap[Color_Indicator + State_Actived_Selected] = textColor;

		colorMap[Color_Indicator + State_Checked] = textColor;
		colorMap[Color_Indicator + State_Checked_Hovered] = textColor % 120;
		colorMap[Color_Indicator + State_Checked_Pressed] = textColor;
		colorMap[Color_Indicator + State_Checked_Selected] = textColor;

		colorMap[Color_Indicator + State_Disable] = textColor % 70;
		colorMap[Color_Indicator + State_Disable_Hovered] = textColor % 120;
		colorMap[Color_Indicator + State_Disable_Pressed] = textColor;
		colorMap[Color_Indicator + State_Disable_Selected] = textColor;

		colorMap[Color_Selection] = color % 160;
		colorMap[Color_Selection + State_Normal] = color % 186;
		colorMap[Color_Selection + State_Normal_Hovered] = color % 136;
		colorMap[Color_Selection + State_Normal_Pressed] = color % 116;
		colorMap[Color_Selection + State_Normal_Selected] = color % 116;

		colorMap[Color_Selection + State_Actived] = color % 186;
		colorMap[Color_Selection + State_Actived_Hovered] = color % 136;
		colorMap[Color_Selection + State_Actived_Pressed] = color % 116;
		colorMap[Color_Selection + State_Actived_Selected] = color % 116;

		colorMap[Color_Selection + State_Checked] = color % 126;
		colorMap[Color_Selection + State_Checked_Hovered] = color % 136;
		colorMap[Color_Selection + State_Checked_Pressed] = color % 116;
		colorMap[Color_Selection + State_Checked_Selected] = color % 116;

		colorMap[Color_Selection + State_Disable] = color % 96;
		colorMap[Color_Selection + State_Disable_Hovered] = color % 136;
		colorMap[Color_Selection + State_Disable_Pressed] = color % 116;
		colorMap[Color_Selection + State_Disable_Selected] = color % 116;

		colorMap[Color_Groove] = color % 120;
		colorMap[Color_Groove + State_Normal] = color % 186;
		colorMap[Color_Groove + State_Normal_Hovered] = color % 136;
		colorMap[Color_Groove + State_Normal_Pressed] = color % 116;
		colorMap[Color_Groove + State_Normal_Selected] = color % 116;

		colorMap[Color_Groove + State_Actived] = color % 186;
		colorMap[Color_Groove + State_Actived_Hovered] = color % 136;
		colorMap[Color_Groove + State_Actived_Pressed] = color % 116;
		colorMap[Color_Groove + State_Actived_Selected] = color % 116;

		colorMap[Color_Groove + State_Checked] = color % 126;
		colorMap[Color_Groove + State_Checked_Hovered] = color % 136;
		colorMap[Color_Groove + State_Checked_Pressed] = color % 116;
		colorMap[Color_Groove + State_Checked_Selected] = color % 116;

		colorMap[Color_Groove + State_Disable] = color % 96;
		colorMap[Color_Groove + State_Disable_Hovered] = color % 136;
		colorMap[Color_Groove + State_Disable_Pressed] = color % 116;
		colorMap[Color_Groove + State_Disable_Selected] = color % 116;

		colorMap[Color_Separator] = textColor;
		colorMap[Color_Separator] = textColor;
		colorMap[Color_Separator + State_Normal] = textColor;
		colorMap[Color_Separator + State_Normal_Hovered] = textColor % 120;
		colorMap[Color_Separator + State_Normal_Pressed] = textColor;
		colorMap[Color_Separator + State_Normal_Selected] = textColor;

		colorMap[Color_Separator + State_Actived] = textColor;
		colorMap[Color_Separator + State_Actived_Hovered] = textColor % 120;
		colorMap[Color_Separator + State_Actived_Pressed] = textColor;
		colorMap[Color_Separator + State_Actived_Selected] = textColor;

		colorMap[Color_Separator + State_Checked] = textColor;
		colorMap[Color_Separator + State_Checked_Hovered] = textColor % 120;
		colorMap[Color_Separator + State_Checked_Pressed] = textColor;
		colorMap[Color_Separator + State_Checked_Selected] = textColor;

		colorMap[Color_Separator + State_Disable] = textColor % 70;
		colorMap[Color_Separator + State_Disable_Hovered] = textColor % 120;
		colorMap[Color_Separator + State_Disable_Pressed] = textColor;
		colorMap[Color_Separator + State_Disable_Selected] = textColor;

		colorMap[Color_Grid_Ver] = color % 120;
		colorMap[Color_Grid_Ver + State_Normal] = color % 120;
		colorMap[Color_Grid_Ver + State_Normal_Hovered] = color % 166;
		colorMap[Color_Grid_Ver + State_Normal_Pressed] = color % 130;
		colorMap[Color_Grid_Ver + State_Normal_Selected] = color % 130;

		colorMap[Color_Grid_Ver + State_Actived] = color % 120;
		colorMap[Color_Grid_Ver + State_Actived_Hovered] = color % 166;
		colorMap[Color_Grid_Ver + State_Actived_Pressed] = color % 130;
		colorMap[Color_Grid_Ver + State_Actived_Selected] = color % 130;

		colorMap[Color_Grid_Ver + State_Checked] = color % 156;
		colorMap[Color_Grid_Ver + State_Checked_Hovered] = color % 166;
		colorMap[Color_Grid_Ver + State_Checked_Pressed] = color % 130;
		colorMap[Color_Grid_Ver + State_Checked_Selected] = color % 130;

		colorMap[Color_Grid_Ver + State_Disable] = color % 50;
		colorMap[Color_Grid_Ver + State_Disable_Hovered] = color % 166;
		colorMap[Color_Grid_Ver + State_Disable_Pressed] = color % 130;
		colorMap[Color_Grid_Ver + State_Disable_Selected] = color % 130;

		colorMap[Color_Grid_Hor] = color % 120;
		colorMap[Color_Grid_Hor + State_Normal] = color % 120;
		colorMap[Color_Grid_Hor + State_Normal_Hovered] = color % 166;
		colorMap[Color_Grid_Hor + State_Normal_Pressed] = color % 130;
		colorMap[Color_Grid_Hor + State_Normal_Selected] = color % 130;

		colorMap[Color_Grid_Hor + State_Actived] = color % 120;
		colorMap[Color_Grid_Hor + State_Actived_Hovered] = color % 166;
		colorMap[Color_Grid_Hor + State_Actived_Pressed] = color % 130;
		colorMap[Color_Grid_Hor + State_Actived_Selected] = color % 130;

		colorMap[Color_Grid_Hor + State_Checked] = color % 156;
		colorMap[Color_Grid_Hor + State_Checked_Hovered] = color % 166;
		colorMap[Color_Grid_Hor + State_Checked_Pressed] = color % 130;
		colorMap[Color_Grid_Hor + State_Checked_Selected] = color % 130;

		colorMap[Color_Grid_Hor + State_Disable] = color % 50;
		colorMap[Color_Grid_Hor + State_Disable_Hovered] = color % 166;
		colorMap[Color_Grid_Hor + State_Disable_Pressed] = color % 130;
		colorMap[Color_Grid_Hor + State_Disable_Selected] = color % 130;

	}

	BStyle* itemStyle = initItemStyle(color);
	BStyle* headerStyle = initHeaderStyle(color);

	boss->addChild("BMenu", "")->addAnnex(itemStyle->clone());
	boss->addChild("BComboBox", "")->addAnnex(itemStyle->clone());
	boss->addChild("BListWidget", "")->addAnnex(itemStyle->clone());
	boss->addChild("BTreeWidget", "")->addAnnex(itemStyle->clone());
	boss->addChild("BHtmlWidget", "")->addAnnex(itemStyle->clone());
	boss->addChild("BGraphicWidget", "")->addAnnex(itemStyle->clone());

	if (BStyle* style = boss->addChild("BTableWidget", ""))
	{
		style->addAnnex(itemStyle->clone());
		style->addAnnex(headerStyle->clone());
	}

	if (BStyle* style = boss->addChild("BTabWidget", ""))
	{
		style->addAnnex(itemStyle->clone());
	}

}
BStyle* member_BStyle::initItemStyle(const BColor& color)
{
	BStyle* style = new BStyle("", "item");
	if (color.gray() > 127)
	{
		style_member(style)->colorMap[Color_Background + State_Normal] = BColor();
		style_member(style)->colorMap[Color_Background + State_Normal_Hovered] = color % 86;
		style_member(style)->colorMap[Color_Background + State_Normal_Pressed] = color % 72;
		style_member(style)->colorMap[Color_Background + State_Normal_Selected] = color % 72;

		style_member(style)->colorMap[Color_Background + State_Actived] = BColor();
		style_member(style)->colorMap[Color_Background + State_Actived_Hovered] = color % 86;
		style_member(style)->colorMap[Color_Background + State_Actived_Pressed] = color % 72;
		style_member(style)->colorMap[Color_Background + State_Actived_Selected] = color % 72;

		style_member(style)->colorMap[Color_Background + State_Checked] = color % 76;
		style_member(style)->colorMap[Color_Background + State_Checked_Hovered] = color % 86;
		style_member(style)->colorMap[Color_Background + State_Checked_Pressed] = color % 72;
		style_member(style)->colorMap[Color_Background + State_Checked_Selected] = color % 72;

		style_member(style)->colorMap[Color_Background + State_Disable] = color % 66;
		style_member(style)->colorMap[Color_Background + State_Disable_Hovered] = color % 86;
		style_member(style)->colorMap[Color_Background + State_Disable_Pressed] = color % 72;
		style_member(style)->colorMap[Color_Background + State_Disable_Selected] = color % 72;
	}
	else
	{
		style_member(style)->colorMap[Color_Background + State_Normal] = BColor();
		style_member(style)->colorMap[Color_Background + State_Normal_Hovered] = color % 186;
		style_member(style)->colorMap[Color_Background + State_Normal_Pressed] = color % 146;
		style_member(style)->colorMap[Color_Background + State_Normal_Selected] = color % 166;

		style_member(style)->colorMap[Color_Background + State_Actived] = BColor();
		style_member(style)->colorMap[Color_Background + State_Actived_Hovered] = color % 186;
		style_member(style)->colorMap[Color_Background + State_Actived_Pressed] = color % 146;
		style_member(style)->colorMap[Color_Background + State_Actived_Selected] = color % 166;

		style_member(style)->colorMap[Color_Background + State_Checked] = color % 176;
		style_member(style)->colorMap[Color_Background + State_Checked_Hovered] = color % 186;
		style_member(style)->colorMap[Color_Background + State_Checked_Pressed] = color % 146;
		style_member(style)->colorMap[Color_Background + State_Checked_Selected] = color % 166;

		style_member(style)->colorMap[Color_Background + State_Disable] = color % 146;
		style_member(style)->colorMap[Color_Background + State_Disable_Hovered] = color % 186;
		style_member(style)->colorMap[Color_Background + State_Disable_Pressed] = color % 146;
		style_member(style)->colorMap[Color_Background + State_Disable_Selected] = color % 166;
	}
	return style;
}
BStyle* member_BStyle::initHeaderStyle(const BColor& color)
{
	BStyle* style = new BStyle("", "header");
	if (color.gray() > 127)
	{
		style_member(style)->colorMap[Color_Background + State_Normal] = BColor();
		style_member(style)->colorMap[Color_Background + State_Normal_Hovered] = color % 86;
		style_member(style)->colorMap[Color_Background + State_Normal_Pressed] = color % 56;
		style_member(style)->colorMap[Color_Background + State_Normal_Selected] = color % 56;

		style_member(style)->colorMap[Color_Background + State_Actived] = BColor();
		style_member(style)->colorMap[Color_Background + State_Actived_Hovered] = color % 86;
		style_member(style)->colorMap[Color_Background + State_Actived_Pressed] = color % 56;
		style_member(style)->colorMap[Color_Background + State_Actived_Selected] = color % 56;

		style_member(style)->colorMap[Color_Background + State_Checked] = color % 166;
		style_member(style)->colorMap[Color_Background + State_Checked_Hovered] = color % 86;
		style_member(style)->colorMap[Color_Background + State_Checked_Pressed] = color % 56;
		style_member(style)->colorMap[Color_Background + State_Checked_Selected] = color % 56;

		style_member(style)->colorMap[Color_Background + State_Disable] = color % 136;
		style_member(style)->colorMap[Color_Background + State_Disable_Hovered] = color % 86;
		style_member(style)->colorMap[Color_Background + State_Disable_Pressed] = color % 56;
		style_member(style)->colorMap[Color_Background + State_Disable_Selected] = color % 56;
	}
	else
	{
		style_member(style)->colorMap[Color_Background + State_Normal] = BColor();
		style_member(style)->colorMap[Color_Background + State_Normal_Hovered] = color % 186;
		style_member(style)->colorMap[Color_Background + State_Normal_Pressed] = color % 166;
		style_member(style)->colorMap[Color_Background + State_Normal_Selected] = color % 166;

		style_member(style)->colorMap[Color_Background + State_Actived] = BColor();
		style_member(style)->colorMap[Color_Background + State_Actived_Hovered] = color % 186;
		style_member(style)->colorMap[Color_Background + State_Actived_Pressed] = color % 166;
		style_member(style)->colorMap[Color_Background + State_Actived_Selected] = color % 166;

		style_member(style)->colorMap[Color_Background + State_Checked] = color % 176;
		style_member(style)->colorMap[Color_Background + State_Checked_Hovered] = color % 186;
		style_member(style)->colorMap[Color_Background + State_Checked_Pressed] = color % 166;
		style_member(style)->colorMap[Color_Background + State_Checked_Selected] = color % 166;

		style_member(style)->colorMap[Color_Background + State_Disable] = color % 136;
		style_member(style)->colorMap[Color_Background + State_Disable_Hovered] = color % 186;
		style_member(style)->colorMap[Color_Background + State_Disable_Pressed] = color % 166;
		style_member(style)->colorMap[Color_Background + State_Disable_Selected] = color % 166;
	}
	return style;
}

bool member_BStyle::apply(BWidget* widget, bool primary) const
{
	bool changed = false;
	for (int i = 0; i < children.size(); i++)
	{
		BStyle* child = children[i];
		if (!primary && !style_member(child)->descendant)
			continue;
		const BString& type = style_member(child)->type;
		if (style_member(child)->heritable)
		{
			if (type.size() && !widget->typed(type))
				continue;
		}
		else
		{
			if (type != widget->className())
				continue;
		}
		const BString& name = object_member(child)->name;
		if (name.size() && name != widget->name())
			continue;
		if (!widget_member(widget)->realStyle)
		{
			widget_member(widget)->realStyle = new BStyle();
		}
		BStyle* realStyle = widget_member(widget)->realStyle;
		style_member(realStyle)->overlap(child);
		changed = true;
	}
	return changed;
}
bool member_BStyle::apply(BLayout* layout, bool primary) const
{
	bool changed = false;
	for (int i = 0; i < children.size(); i++)
	{
		BStyle* child = children[i];
		if (!primary && !style_member(child)->descendant)
			continue;
		const BString& type = style_member(child)->type;
		if (style_member(child)->heritable)
		{
			if (type.size() && !layout->typed(type))
				continue;
		}
		else
		{
			if (type != layout->className())
				continue;
		}
		const BString& name = object_member(child)->name;
		if (name.size() && name != layout->name())
			continue;
		if (!layout_member(layout)->realStyle)
		{
			layout_member(layout)->realStyle = new BStyle();
		}
		BStyle* realStyle = layout_member(layout)->realStyle;
		style_member(realStyle)->overlap(child);
		changed = true;
	}
	return changed;
}
bool member_BStyle::apply(IAlignItem* item) const
{
	BObject* object = item->object;
	if (!object)
		return false;
	bool changed = false;
	for (int i = 0; i < children.size(); i++)
	{
		BStyle* child = children[i];
		const BString& type = style_member(child)->type;
		if (style_member(child)->heritable)
		{
			if (type.size() && !object->typed(type))
				continue;
		}
		else
		{
			if (type != object->className())
				continue;
		}
		const BString& name = object_member(child)->name;
		if (name.size() && name != object->name())
			continue;
		if (!item->realStyle)
		{
			item->realStyle = new BStyle();
		}
		BStyle* realStyle = item->realStyle;
		style_member(realStyle)->overlap(child);
		changed = true;
	}
	return changed;
}
bool member_BStyle::apply(BGraphicItem* item) const
{
	bool changed = false;
	for (int i = 0; i < children.size(); i++)
	{
		BStyle* child = children[i];
		const BString& type = style_member(child)->type;
		if (style_member(child)->heritable)
		{
			if (type.size() && !item->typed(type))
				continue;
		}
		else
		{
			if (type != item->className())
				continue;
		}
		const BString& name = object_member(child)->name;
		if (name.size() && name != item->name())
			continue;
		if (!item_member(item)->realStyle)
		{
			item_member(item)->realStyle = new BStyle();
		}
		BStyle* realStyle = item_member(item)->realStyle;
		style_member(realStyle)->overlap(child);
		changed = true;
	}
	return changed;
}
void member_BStyle::overlap(const BStyle* style)
{
	if (style == 0)
		return;
	if (style == boss)
		return;
	if (style_member(style)->unset.size())
	{
		if (style_member(style)->unset == "all")
			boss->clearAll();
		else if (style_member(style)->unset == "values")
			boss->clearValues();
		else if (style_member(style)->unset == "colors")
			boss->clearColors();
		else if (style_member(style)->unset == "images")
			boss->clearImages();
		else if (style_member(style)->unset == "icons")
			boss->clearIcons();
		else if (style_member(style)->unset == "trans")
			boss->clearTrans();
		else if (style_member(style)->unset == "words")
			boss->clearWords();
		else if (style_member(style)->unset == "texts")
			boss->clearTexts();
	}

	if (style_member(style)->valueMap.size())
	{
		for (auto it = style_member(style)->valueMap.begin(); it.valid(); it++)
		{
			valueMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->colorMap.size())
	{
		for (auto it = style_member(style)->colorMap.begin(); it.valid(); it++)
		{
			colorMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->imageMap.size())
	{
		for (auto it = style_member(style)->imageMap.begin(); it.valid(); it++)
		{
			imageMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->iconMap.size())
	{
		for (auto it = style_member(style)->iconMap.begin(); it.valid(); it++)
		{
			iconMap[it.key()] = it.value();
		}
	}

	if (style_member(style)->namedValueMap.size())
	{
		for (auto it = style_member(style)->namedValueMap.begin(); it.valid(); it++)
		{
			namedValueMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->namedColorMap.size())
	{
		for (auto it = style_member(style)->namedColorMap.begin(); it.valid(); it++)
		{
			namedColorMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->namedImageMap.size())
	{
		for (auto it = style_member(style)->namedImageMap.begin(); it.valid(); it++)
		{
			namedImageMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->namedIconMap.size())
	{
		for (auto it = style_member(style)->namedIconMap.begin(); it.valid(); it++)
		{
			namedIconMap[it.key()] = it.value();
		}
	}

	if (style_member(style)->transMap.size())
	{
		for (auto it = style_member(style)->transMap.begin(); it.valid(); it++)
		{
			transMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->wordMap.size())
	{
		for (auto it = style_member(style)->wordMap.begin(); it.valid(); it++)
		{
			wordMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->textMap.size())
	{
		for (auto it = style_member(style)->textMap.begin(); it.valid(); it++)
		{
			textMap[it.key()] = it.value();
		}
	}

	if (style_member(style)->annexes.size())
	{
		for (int i = 0; i < style_member(style)->annexes.size(); i++)
		{
			BStyle* annex = style_member(style)->annexes[i];
			member_BStyle* smem = style_member(annex);
			BStyle* newAnnex = boss->annex(annex->name());
			if (newAnnex)
			{
				style_member(newAnnex)->overlap(annex);
			}
			else
			{
				newAnnex = new BStyle(*annex);
				annexes.append(newAnnex);
			}
		}
	}
	if (style_member(style)->children.size())
	{
		for (int i = 0; i < style_member(style)->children.size(); i++)
		{
			BStyle* child = style_member(style)->children[i];
			if (children.lower(child))
				continue;
			children.append(child);
		}
	}
}

bool member_BStyle::setMetaValue(const BString& name, BString& value)
{
	if (value.empty() || !value.isNumber())
		return false;
	value.lower();
	if (value == "false")
	{
		namedValueMap[name] = false;
		return true;
	}
	if (value == "true")
	{
		namedValueMap[name] = true;
		return true;
	}
	if (value.contain('e'))
	{
		if (value.endWith('f'))
			namedValueMap[name] = strtof(value.cstr(), 0);
		else
			namedValueMap[name] = strtod(value.cstr(), 0);
		return true;
	}
	if (value.contain('.'))
	{
		if (value.endWith('f'))
			namedValueMap[name] = value.toFloat();
		else
			namedValueMap[name] = value.toDouble();
		return true;
	}
	namedValueMap[name] = value.toInt();
	return true;
}
bool member_BStyle::setBoolValue(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = 0;
	else if (value == "true" || value == "on")
		valueMap[name] = true;
	else if (value == "false" || value == "off")
		valueMap[name] = false;
	else
		return false;
	return true;
}
bool member_BStyle::setIntValue(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = 0;
	else if (value.isNumber())
		valueMap[name] = value.toInt();
	else
		return false;
	return true;
}
bool member_BStyle::setWordValue(StyleValue name, const BString& value)
{
	int val = 0xF0F0;
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = 0;
	else if (value.beginWith("0x"))
		valueMap[name] = (BUShort)bHexToShort(value.cstr() + 2);
	else if (value.isAlpha(0))
	{
		for (int i = 0; i < value.size(); i++)
		{
			if (!value.isPunct(i))
				return false;
		}
		valueMap[name] = (BUShort)bHexToShort(value.cstr());
	}
	else if (value.isNumber())
		valueMap[name] = (BUShort)value.toUInt();
	else
		return false;
	return true;
}
bool member_BStyle::setFloatValue(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = 0;
	else if (value.isNumber())
		valueMap[name] = value.toFloat();
	else
		return false;
	return true;
}
bool member_BStyle::setPointValue(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = BPoint();
	else if (value.contain(','))
	{
		BStringArray words;
		value.split(words, ',');
		if (words.size() != 2)
			return false;
		int x = words[0].toInt();
		int y = words[1].toInt();
		valueMap[name] = BPoint(x, y);
		return true;
	}
	else if (value.isNumber())
		valueMap[name] = BPoint(value.toInt());
	else
		return false;
	return true;
}
bool member_BStyle::setSizeValue(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = BSize();
	else if (value.contain(','))
	{
		BStringArray words;
		value.split(words, ',');
		if (words.size() != 2)
			return false;
		int width = words[0].toInt();
		int height = words[1].toInt();
		valueMap[name] = BSize(width, height);
	}
	else if (value.isNumber())
		valueMap[name] = BSize(value.toInt());
	else
		return false;
	return true;
}

bool member_BStyle::setAlignValue(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = (Align)Align_None;
	else if (value == "top")
		valueMap[name] = Align_Top;
	else if (value == "left")
		valueMap[name] = Align_Left;
	else if (value == "right")
		valueMap[name] = Align_Right;
	else if (value == "bottom")
		valueMap[name] = Align_Bottom;
	else if (value == "center")
		valueMap[name] = Align_Center;
	else if (value == "left-center")
		valueMap[name] = Align_LeftCenter;
	else if (value == "right-center")
		valueMap[name] = Align_RightCenter;
	else if (value == "top-center")
		valueMap[name] = Align_TopCenter;
	else if (value == "bottom-center")
		valueMap[name] = Align_BottomCenter;
	else if (value.contain('|'))
	{
		Align align = Align_None;
		BString word;
		int pos = 0;
		while (pos < value.size())
		{
			pos = value.word(word, pos);
			if (word == '|')
				continue;
			else if (word == "left")
				((int&)align) |= Align_Left;
			else if (word == "right")
				((int&)align) |= Align_Right;
			else if (word == "top")
				((int&)align) |= Align_Top;
			else if (word == "bottom")
				((int&)align) |= Align_Bottom;
			else if (word == "hcenter")
				((int&)align) |= Align_HCenter;
			else if (word == "vcenter")
				((int&)align) |= Align_VCenter;
			else
				return false;
		}
		if (align == Align_None)
			return false;
		valueMap[name] = align;
		return true;
	}
	else
		return false;
	return true;
}
bool member_BStyle::setPartValue(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = (Part)Part_None;
	else if (value == "top")
		valueMap[name] = Part_Top;
	else if (value == "left")
		valueMap[name] = Part_Left;
	else if (value == "right")
		valueMap[name] = Part_Right;
	else if (value == "bottom")
		valueMap[name] = Part_Bottom;
	else if (value == "center")
		valueMap[name] = Part_Center;
	else if (value == "left-center")
		valueMap[name] = Part_LeftCenter;
	else if (value == "right-center")
		valueMap[name] = Part_RightCenter;
	else if (value == "top-center")
		valueMap[name] = Part_TopCenter;
	else if (value == "bottom-center")
		valueMap[name] = Part_BottomCenter;
	else if (value.contain('|'))
	{
		Part part = Part_None;
		BString word;
		int pos = 0;
		while (pos < value.size())
		{
			pos = value.word(word, pos);
			if (word == '|')
				continue;
			else if (word == "left")
				((int&)part) |= Part_Left;
			else if (word == "right")
				((int&)part) |= Part_Right;
			else if (word == "top")
				((int&)part) |= Part_Top;
			else if (word == "bottom")
				((int&)part) |= Part_Bottom;
			else if (word == "center")
				((int&)part) |= Part_Center;
			else
				return false;
		}
		if (part == Part_None)
			return false;
		valueMap[name] = part;
		return true;
	}
	else
		return false;
	return true;
}
bool member_BStyle::setFormValue(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = Form_None;
	else if (value == "icon-alone")
		valueMap[name] = Form_IconAlone;
	else if (value == "text-alone")
		valueMap[name] = Form_TextAlone;
	else if (value == "text-only")
		valueMap[name] = Form_TextOnly;
	else if (value == "icon-only")
		valueMap[name] = Form_IconOnly;
	else if (value == "icon-text")
		valueMap[name] = Form_IconText;
	else if (value == "text-icon")
		valueMap[name] = Form_TextIcon;
	else if (value == "text-under-icon" || value == "icon-above-text")
		valueMap[name] = Form_TextUnderIcon;
	else if (value == "icon-under-text" || value == "text-above-icon")
		valueMap[name] = Form_IconUnderText;
	else if (value == "icon-text-overlap" || value == "overlap")
		valueMap[name] = Form_IconTextOverlap;
	else
		return false;
	return true;
}
bool member_BStyle::setGraphValue(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = Graph_None;
	else if (value == "circle")
		valueMap[name] = Graph_Circle;
	else if (value == "circle-fill")
		valueMap[name] = Graph_Circle_Fill;
	else if (value == "square")
		valueMap[name] = Graph_Square;
	else if (value == "square-fill")
		valueMap[name] = Graph_Square_Fill;
	else if (value == "round")
		valueMap[name] = Graph_Round;
	else if (value == "round-fill")
		valueMap[name] = Graph_Round_Fill;
	else if (value == "arrow-up")
		valueMap[name] = Graph_Arrow_Up;
	else if (value == "arrow-up-fill")
		valueMap[name] = Graph_Arrow_Up_Fill;
	else if (value == "arrow-down")
		valueMap[name] = Graph_Arrow_Down;
	else if (value == "arrow-down-fill")
		valueMap[name] = Graph_Arrow_Down_Fill;
	else if (value == "arrow-left")
		valueMap[name] = Graph_Arrow_Left;
	else if (value == "arrow-left-fill")
		valueMap[name] = Graph_Arrow_Left_Fill;
	else if (value == "arrow-right")
		valueMap[name] = Graph_Arrow_Right;
	else if (value == "arrow-right-fill")
		valueMap[name] = Graph_Arrow_Right_Fill;

	else if (value == "arrow-left-top")
		valueMap[name] = Graph_Arrow_LeftTop;
	else if (value == "arrow-left-top-fill")
		valueMap[name] = Graph_Arrow_LeftTop_Fill;
	else if (value == "arrow-right-top")
		valueMap[name] = Graph_Arrow_RightTop;
	else if (value == "arrow-right-top-fill")
		valueMap[name] = Graph_Arrow_RightTop_Fill;
	else if (value == "arrow-left-bottom")
		valueMap[name] = Graph_Arrow_LeftBottom;
	else if (value == "arrow-left-bottom-fill")
		valueMap[name] = Graph_Arrow_LeftBottom_Fill;
	else if (value == "arrow-right-bottom")
		valueMap[name] = Graph_Arrow_RightBottom;
	else if (value == "arrow-right-bottom-fill")
		valueMap[name] = Graph_Arrow_RightBottom_Fill;

	else if (value == "plus")
		valueMap[name] = Graph_Plus;
	else if (value == "minus")
		valueMap[name] = Graph_Minus;
	else if (value == "cross")
		valueMap[name] = Graph_Cross;
	else if (value == "maximize")
		valueMap[name] = Graph_Maximize;
	else if (value == "minimize")
		valueMap[name] = Graph_Minimize;
	else if (value == "normalize")
		valueMap[name] = Graph_Normalize;
	else
		return false;
	return true;
}
bool member_BStyle::setPolicyValue(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = (Policy)Policy_None;
	else if (value == "fixed")
		valueMap[name] = (Policy)Policy_Fixed;
	else if (value == "preferred")
		valueMap[name] = (Policy)Policy_Preferred;
	else if (value == "expanding")
		valueMap[name] = (Policy)Policy_Expanding;
	else if (value == "shrinking")
		valueMap[name] = (Policy)Policy_Shrinking;
	else if (value == "dynamic")
		valueMap[name] = (Policy)Policy_Dynamic;
	else if (value == "growing")
		valueMap[name] = (Policy)Policy_Growing;
	else if (value == "limited")
		valueMap[name] = (Policy)Policy_Limited;
	else if (value.contain('|'))
	{
		Policy policy = Policy_None;
		BString word;
		int pos = 0;
		while (pos < value.size())
		{
			pos = value.word(word, pos);
			if (word == '|')
				continue;
			else if (word == "fixed")
				policy |= Policy_Fixed;
			else if (word == "preferred")
				policy |= Policy_Preferred;
			else if (word == "expanding")
				policy |= Policy_Expanding;
			else if (word == "shrinking")
				policy |= Policy_Shrinking;
			else if (value == "growing")
				policy |= Policy_Growing;
			else if (value == "limited")
				policy |= Policy_Limited;
			else if (word == "dynamic")
				policy |= Policy_Dynamic;
		}
		if (policy == Policy_None)
			return false;
		valueMap[name] = policy;
		return true;
	}
	return true;
}
bool member_BStyle::setOrientation(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = (Orientation)Orientation_None;
	else if (value == "horizontal")
		valueMap[name] = (Orientation)Orientation_Horizontal;
	else if (value == "vertical")
		valueMap[name] = (Orientation)Orientation_Vertical;
	else if (value == "crossing")
		valueMap[name] = (Orientation)Orientation_Crossing;
	else if (value == "reverse")
		valueMap[name] = (Orientation)Orientation_Reverse;
	else if (value.contain('|'))
	{
		Orientation orientation = Orientation_None;
		BString word;
		int pos = 0;
		while (pos < value.size())
		{
			pos = value.word(word, pos);
			if (word == '|')
				continue;
			else if (word == "horizontal")
				orientation |= Orientation_Horizontal;
			else if (word == "vertical")
				orientation |= Orientation_Vertical;
			else if (word == "crossing")
				orientation |= Orientation_Crossing;
			else if (word == "reverse")
				orientation |= Orientation_Reverse;
		}
		if (orientation == Orientation_None)
			return false;
		valueMap[name] = orientation;
		return true;
	}
	return true;
}
bool member_BStyle::setScrollStep(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = ScrollHint_None;
	else if (value.isNumber())
		valueMap[name] = value.toFloat();
	else
		return false;
	return true;
}
bool member_BStyle::setScrollHint(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = ScrollHint_None;
	if (value == "auto")
		valueMap[name] = ScrollHint_Auto;
	else if (value == "always")
		valueMap[name] = ScrollHint_Always;
	else if (value == "floating")
		valueMap[name] = ScrollHint_Floating;
	else
		return false;
	return true;
}
bool member_BStyle::setGridStyle(StyleValue name, const BString& value)
{
	if (value == "unset")
		valueMap.remove(name);
	else if (value == "revert")
		valueMap[name].clear();
	else if (value == "none")
		valueMap[name] = Grid_None;
	if (value == "vertical")
		valueMap[name] = Grid_Vertical;
	if (value == "horizontal")
		valueMap[name] = Grid_Horizontal;
	if (value == "crossing")
		valueMap[name] = Grid_Crossing;
	else
		return false;
	return true;
}

void member_BStyle::raiseSignal(int signal, const BValue& value)
{
	BStyle* style = boss;
	while (style)
	{
		style->emit(signal, value);
		style = style_member(style)->parent;
	}
}
